Reproducing Temporal Pointwise Convolutional Networks for Length of Stay Prediction in the Intensive Care Unit#1021
Open
meduk2 wants to merge 25 commits intosunlabuiuc:masterfrom
Open
Reproducing Temporal Pointwise Convolutional Networks for Length of Stay Prediction in the Intensive Care Unit#1021meduk2 wants to merge 25 commits intosunlabuiuc:masterfrom
meduk2 wants to merge 25 commits intosunlabuiuc:masterfrom
Conversation
Summary:
- Added end-to-end pipeline for reproducing TPC-style LoS prediction using PyHealth
- Verified data loading, task transformation, and model training loop
New files:
- pyhealth/models/tpc.py
- Implements Temporal Pointwise Convolution (TPC) model as BaseModel subclass
- Includes temporal + pointwise convolution blocks and regression head
- pyhealth/tasks/hourly_los.py
- Custom BaseTask implementation for hourly remaining length-of-stay prediction
- Uses eICU patient + lab event partitions
- Converts labresultoffset (minutes) → hourly time bins
- Generates causal samples (t -> remaining LoS)
- examples/eicu_hourly_los_tpc.py
- End-to-end example script
- Loads eICU dataset (dev mode)
- Applies HourlyLOSEICU task
- Wraps samples into PyTorch Dataset + DataLoader
- Trains TPC model with MSLE loss
Key design decisions:
- Used event_type_partitions + get_events() API (no visit abstraction in this branch)
- Treated each Patient object as a stay-level sequence
- Used labresultoffset instead of timestamp (timestamp is synthetic)
- Started with single feature ('-basos') for pipeline validation
Current status:
- Task successfully generates ~28k samples from 1000 patients (dev mode)
- Training loop runs end-to-end
- Loss decreases across epochs (sanity check passed)
Limitations / TODO:
- Only 1 lab feature currently used
- No forward-fill or masking yet
- No static features
- Not yet aligned with full paper feature set
- TPC architecture is simplified vs paper
Next steps:
- Expand to multiple lab features
- Add forward-fill + missingness indicators
- Incorporate additional tables (if supported)
- Align model architecture with original paper
Notes:
- Requires running with PYTHONPATH=. to use local PyHealth modifications
- i.e PYTHONPATH=. python3 examples/eicu_hourly_los_tpc.py
…al split, channel ablations, and categorical static encoding
…ime in ICU, time of day)
…riments - Implement TPC model with temporal + pointwise branches - Add configurable ablations (temporal_only, pointwise_only, shared_temporal, no_skip_connections) - Support MSLE and MSE loss options - Add synthetic smoke test and full eICU example pipeline - Add unit tests for model forward pass and hourly LoS task - Conduct hyperparameter sensitivity experiments (Extension 1) This commit enables full hypothesis evaluation (H1–H4) and Extension 1.
- Included Paper link - Included Ablations and model comparison details from our deck - Included the index file changes and updated file structure with the same.
…c.py now inherits BaseModel
…ript for proper cache handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR reproduces the Temporal Pointwise Convolution (TPC) model and introduces a new hourly ICU length-of-stay prediction task in PyHealth.
All implementation, tests, and example pipelines are included. The contribution follows PyHealth BaseModel and task conventions and includes fast synthetic tests for reproducibility.
Primary files:
CS598 Deep Learning for Healthcare Project
This PR reproduces and contributes an implementation of:
Temporal Pointwise Convolutional Networks for Length of Stay Prediction in the Intensive Care Unit
Rocheteau et al., ACM CHIL 2021
Paper: https://arxiv.org/abs/2007.09483
Contributors
meduk2@illinois.edu)kylee7@illinois.edu)tanmayt3@illinois.edu)PR Overview
Contribution Types
This PR includes:
Problem Overview
Efficient ICU bed management depends critically on estimating how long a patient will remain in the ICU.
This is formulated as:
We follow the formulation in the original paper, predicting remaining LoS at each hour of the ICU stay.
Implementation Details
1) Model Contribution
pyhealth.models.tpc
We implement the Temporal Pointwise Convolution (TPC) model as a PyHealth-compatible model by extending BaseModel and follows the original paper’s architecture with adaptations for PyHealth’s input/output interfaces. Index files were updated to include the new modules accordingly.
2) Task Contribution
We implement a custom PyHealth task: Hourly Remaining Length of Stay. Index files were updated to include the new modules accordingly.
pyhealth.tasks.hourly_los
Task Definition
Motivation
3) Ablation Study/ Example Usage
We implemented scripts for runnning the pipeline end to end with support for different experiemental setups or ablations.
examples/eicu_hourly_los_tpc.py : This provides an end-to-end script for reproducing and evaluating pipeline on EICU dataset.
examples/mimic4_hourly_los_tpc.py : This provides an end-to-end script for reproducing and evaluating pipeline on MIMIC-IV dataset.
examples/run_dual_dataset_tpc.py : This utility scripts runs the pipeline on both datasets and produces a combined report.
4) Test Cases
We implemented fast performing test cases for our Model and Task contribution using Sythentic Data.
tests/models/test_tpc.py
tests/tasks/test_hourly_los.py
Experimental Setup and Findings
2) Comparison across using combined temporal and pointwise convolutions vs using either architecture alone.
3) Feature independant (no weight-sharing) vs weight-shared temporal convolutions.
4) Evaluating MSLE loss vs MSE loss for skewed LoS target regression.
## Testing model with varying hyperparameters.
We varied key optimization and architectural hyperparameters (e.g. learning rate, dropout rate, etc) while keeping preprocessing and data splits fixed.
File Structure
Setup
Quick Start (Synthetic Data)
eICU example
MIMIC-IV example
Combined dual-dataset run
Notes on Real Data
For full eICU or MIMIC-IV experiments, point
EICU_ROOTorMIMIC4_ROOTto the real dataset locations and increase settings such as--epochs,--batch_size, and--max_samplesas needed.Tests
Run the project-specific tests with:
Documentation
API documentation entries were added for:
pyhealth.models.tpcpyhealth.tasks.hourly_losOutput
The example scripts print compact summary lines for quick validation:
ABLATION_SUMMARYfor eICUMIMIC_SUMMARYfor MIMIC-IVThe dual-dataset runner parses both and prints a combined summary table.
Environment
This project is designed to run within the PyHealth environment.
Recommended setup:
Install PyHealth and dependencies following the main repository instructions.